# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Jürgen Pfeifer <juergen@familiepfeifer.de>

_realname=qrupdate

pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}-svn
pkgver=r28
pkgrel=1
pkgdesc="qrupdate is a Fortran library for fast updates of QR and Cholesky decompositions."
arch=('any')
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
url="http://qrupdate.sourceforge.net/"
options=('strip' 'staticlibs')
license=('GPL' 'LGPL')
groups=("${MINGW_PACKAGE_PREFIX}")
makedepends=("subversion"
    "${MINGW_PACKAGE_PREFIX}-gcc-fortran")
depends=("${MINGW_PACKAGE_PREFIX}-OpenBLAS")
source=("$_realname::svn+http://svn.code.sf.net/p/qrupdate/code")
md5sums=('SKIP')

pkgver() {
  cd "$srcdir/$_realname"
  local ver="$(svnversion)"
  printf "r%s" "${ver//[[:alpha:]]}"
}

build() {
  mkdir -p ${srcdir}/build-${CARCH} && cd ${srcdir}/build-${CARCH}
  cp -pR ../$_realname/* .
  make FPICFLAGS="" lib
  gfortran -shared -o lib${_realname}.dll -Wl,--out-implib,lib${_realname}.dll.a src/*.o -lopenblas -lgfortran
}

package() {
  cd ${srcdir}/build-${CARCH}
  mkdir -p ${pkgdir}${MINGW_PREFIX}/bin
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib
  cp -pf lib${_realname}.dll ${pkgdir}${MINGW_PREFIX}/bin
  cp -pf lib${_realname}*.a ${pkgdir}${MINGW_PREFIX}/lib
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname  
  cp -pf ${srcdir}/${_realname}/COPYING* \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname
}
